package com.project.service.impl;

import com.project.bean.EmployeeBean;
import com.project.mapper.IEmployeeMapper;
import com.project.service.IEmployeeService;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;

import java.time.LocalDate;

/***
 * 员工业务接口实现类
 */
public class EmployeeServiceImpl extends BaseService implements IEmployeeService {
    @Override
    public void add(EmployeeBean employeeBean) {
          //得到SqlSession
        SqlSession sqlSession = this.getSession();
        //得到IEmployeeMapper实现类对象
        IEmployeeMapper mapper =   sqlSession.getMapper(IEmployeeMapper.class);
        mapper.add(employeeBean);
        //提交事务
        sqlSession.commit();
        //关闭sqlSession
        sqlSession.close();
    }

    @Override
    public void del(int id) {
        SqlSession session = this.getSession();
        IEmployeeMapper mapper = session.getMapper(IEmployeeMapper.class);
        mapper.del(id);
        //提交事务
        session.commit();
        //关闭sqlSession
        session.close();
    }

    @Override
    public void update( int id, LocalDate date) {
        SqlSession session = this.getSession();
     IEmployeeMapper mapper =   session.getMapper(IEmployeeMapper.class);
     mapper.update(id,date);
     session.commit();
     session.close();
    }
}
